
var  crypto = require('crypto');


// 定义加密函数
function encrypt(text, key) {
    const cipher = crypto.createCipher('aes-256-cbc', key);
    let encrypted = cipher.update(text, 'utf8', 'hex');
    encrypted += cipher.final('hex');
    return encrypted;
}

// 定义解密函数
function decrypt(encrypted, key) {
    const decipher = crypto.createDecipher('aes-256-cbc', key);
    let decrypted = decipher.update(encrypted, 'hex', 'utf8');
    decrypted += decipher.final('utf8');
    return decrypted;
}


	// 公用模块用法请参考 https://uniapp.dcloud.io/uniCloud/cf-common
module.exports = {
	encrypt,
	decrypt
}
